//    PollIT - Tool to make decisions of anything.
//    Copyright (C) 2011 Jukka Hell
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

import com.mchange.v2.c3p0.ComboPooledDataSource
import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH
import grails.util.GrailsUtil

// Place your Spring DSL code here
beans = {
    if (GrailsUtil.environment != "test") {
        dataSource(ComboPooledDataSource) { bean ->
            bean.destroyMethod = "close"
            user = CH.config.dataSource.username
            password = CH.config.dataSource.password
            driverClass = CH.config.dataSource.driverClassName
            jdbcUrl = CH.config.dataSource.url

            maxStatements = 180 // prepared statement pooling maxConnectionAge = 4 * 60 * 60 // 4 hours
            initialPoolSize = 5
            maxPoolSize = 20
            minPoolSize = 5
            acquireIncrement = 3
            idleConnectionTestPeriod = 3600
            maxIdleTime = 10800
        }
    }
}